<div class="noprint">
<?php include_partial('globals/backoffice_menu') ?>
</div>
<?php include_component('globals', 'restaurantDropdown', array('html_id' => 'restaurant_select')) ?>
<div class="noprint">
<?php include_component('globals', 'console') ?>
</div>

<div class="noprint">
<table>
    <tr>
        <td>
			<a class="reservation_button_week_day"
               href="<?php echo url_for('@reservation_list?date=' . Util::offsetTodayDate(date('Y-m-d'), 0)) ?>">
			   <div type="button" class="ui-button ui-widget ui-state-active ui-corner-all ui-button-text-only yvo-smallbutton " role="button">
					<span class="ui-button-text yvo-smalltext">
							<?php echo __('Today') ?><br />
							<?php echo Util::getShortDate(date('Y-m-d')) ?>					
					</span>
				</div>
			</a>
        </td>
        <td>
			<a class="reservation_button_week_day"
               href="<?php echo url_for('@reservation_list?date=' . Util::offsetTodayDate(date('Y-m-d'), 1)) ?>">
			   <div type="button" class="ui-button ui-widget ui-state-active ui-corner-all ui-button-text-only yvo-smallbutton " role="button">
					<span class="ui-button-text yvo-smalltext">
							<?php echo __('Tomorrow') ?><br />
							<?php echo Util::getShortDate(Util::offsetTodayDate(date('Y-m-d'), 1)) ?>					
					</span>
				</div>
			</a>
        </td>
        <td>
			<a class="reservation_button_week_day"
               href="<?php echo url_for('@reservation_list?date=' . Util::offsetTodayDate(date('Y-m-d'), 2)) ?>">
			   <div type="button" class="ui-button ui-widget ui-state-active ui-corner-all ui-button-text-only yvo-smallbutton " role="button">
					<span class="ui-button-text yvo-smalltext">
							<?php echo format_date(Util::offsetTodayDate(date('Y-m-d'), 2),'EEEE', 'nl') ?><br />
							<?php echo Util::getShortDate(Util::offsetTodayDate(date('Y-m-d'), 2)) ?>
											
					</span>
				</div>
			</a>
        </td>
        <td>
            <a class="reservation_button_week_day"
               href="<?php echo url_for('@reservation_list?date=' . Util::offsetTodayDate(date('Y-m-d'), 3)) ?>">
			   <div type="button" class="ui-button ui-widget ui-state-active ui-corner-all ui-button-text-only yvo-smallbutton " role="button">
					<span class="ui-button-text yvo-smalltext">
							<?php echo format_date(Util::offsetTodayDate(date('Y-m-d'), 3),'EEEE', 'nl') ?><br />
							<?php echo Util::getShortDate(Util::offsetTodayDate(date('Y-m-d'), 3)) ?>					
					</span>
				</div>
			</a>
        </td>
        <td>
            <a class="reservation_button_week_day"
               href="<?php echo url_for('@reservation_list?date=' . Util::offsetTodayDate(date('Y-m-d'), 4)) ?>">
			   <div type="button" class="ui-button ui-widget ui-state-active ui-corner-all ui-button-text-only yvo-smallbutton " role="button">
					<span class="ui-button-text yvo-smalltext">
							<?php echo format_date(Util::offsetTodayDate(date('Y-m-d'), 4),'EEEE', 'nl') ?><br />
							<?php echo Util::getShortDate(Util::offsetTodayDate(date('Y-m-d'), 4)) ?>					
					</span>
				</div>
			</a>
        </td>
        <td>
            <a class="reservation_button_week_day"
               href="<?php echo url_for('@reservation_list?date=' . Util::offsetTodayDate(date('Y-m-d'), 5)) ?>">
			   <div type="button" class="ui-button ui-widget ui-state-active ui-corner-all ui-button-text-only yvo-smallbutton " role="button">
					<span class="ui-button-text yvo-smalltext">
							<?php echo format_date(Util::offsetTodayDate(date('Y-m-d'), 5),'EEEE', 'nl') ?><br />
							<?php echo Util::getShortDate(Util::offsetTodayDate(date('Y-m-d'), 5)) ?>					
					</span>
				</div>
			</a>
        </td>
        <td>
            <a class="reservation_button_week_day"
               href="<?php echo url_for('@reservation_list?date=' . Util::offsetTodayDate(date('Y-m-d'), 6)) ?>">
			   <div type="button" class="ui-button ui-widget ui-state-active ui-corner-all ui-button-text-only yvo-smallbutton " role="button">
					<span class="ui-button-text yvo-smalltext">
							<?php echo format_date(Util::offsetTodayDate(date('Y-m-d'), 6),'EEEE', 'nl') ?><br />
							<?php echo Util::getShortDate(Util::offsetTodayDate(date('Y-m-d'), 6)) ?>					
					</span>
				</div>
			</a>
        </td>
    </tr>
</table>

<table>
    <tr>
        <td><?php echo __('Date') ?></td>
        <td>
            <form id="reservationListDateForm">
            <input type="text" id="reservation_list_date" value="<?php echo Util::convertDateServerClient($sf_request->getParameter('date')) ?>"/>
            </form>
        </td>
        <td>
            <?php include_component('globals', 'specialDates') ?>
        </td>
    </tr>
</table>
</div><?php //noprint end ?>
<div class="ui-widget">
	<div class="ui-state-highlight ui-corner-all">
		<div class="yvo-indent50">

			<strong><?php echo decideTodayOrTomorrow($sf_params->get('date')) ?><?php echo format_date($sf_params->get('date'), 'D') ?></strong>
			<?php //echo decideSpecialDate($sf_params->get('date'), $special_dates) ?>
			<a class="reservation_button_week_day" href="#" onclick="window.print();">
				<div type="button" class="ui-button ui-widget ui-state-active ui-corner-all ui-button-text-only yvo-smallbutton " role="button">
					<span class="ui-button-text yvo-smalltext">
						<?php echo __('Print') ?>
					</span>
				</div>
			</a>
		</div>
	</div>
</div>


<table cellpadding="7" cellspacing="7">
    <?php foreach ($day_intervals as $day_interval): ?>
        <tr>
            <td colspan="3"><strong><?php echo $day_interval['name'] ?> <?php echo $day_interval['time_start']?>-<?php echo $day_interval['time_end']?></strong></td>
        </tr>
        <?php if (!empty($reservations[$day_interval['name']])): ?>
        <?php foreach ($reservations as $interval_name => $reservations_array): ?>
            <?php foreach ($reservations_array as $time => $reservations): ?>
                <?php if (!empty($reservations)): ?>
                <?php $total_persons = 0 ?>
                <tr>
                    <td valign="top"><a href=""><strong><?php echo $time ?></strong></a></td>
                    <td valign="top">
                        <table cellpadding="0" cellspacing="0" border="1">
                            <?php foreach ($reservations as $reservation): ?>
                            <tr>
                                <td width="50" align="right"><strong><?php echo $reservation['person_no'] ?></strong></td>
                                <td width="20">&nbsp;</td>
                                <td>
                                    <a href="<?php echo url_for('@reservation_backoffice_edit?id=' . $reservation['reservation_id']) ?>">
                                   <?php // FIXME: set NOT the id, but the hash here - issue #48 ; ?>
	                                    <strong>
	                                   		 <?php if ( $reservation['name_first'] ) {
	                                    	 	echo $reservation['name_first'] . " ";
	                                    	 }
	                                    	 
	                                    	 // TODO: Hartger - add company etc.
	                                    	 ?>
	                                    	
	                                    	<?php echo $reservation['name_last'] ?> (tel: <?php echo $reservation['phone'] ?>)
	                                    	<?php 
	                                    	 if ( $reservation['comments_diet'] ) {
	                                    	 	echo " - Opm: " . $reservation['comments_diet'];
	                                    	 }
	                                    	?>
	                                    </strong>
                                    </a> &nbsp;
                                    <?php echo $reservation['comments_general'] ?>
                                </td>
                            </tr>
                            <?php $total_persons += $reservation['person_no'] ?>
                            <?php endforeach ?>
                        </table>
                    </td>
                    <tr>
                        <td valign="top">&nbsp;</td>
                        <td valign="top">
                            <table cellpadding="0" cellspacing="0">
                                <tr>
                                    <td style="border-top-style: solid; border-top-width: 1px; border-color: black" align="right" width="50">
                                        <strong><?php echo count($reservations) ?> / <?php echo $total_persons ?></strong>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </tr>
                <?php endif ?>
            <?php endforeach ?>
        <?php endforeach ?>
        <?php else: ?>
            <tr>
                <td valign="top">&nbsp;</td>
                <td valign="top">
                    <table cellpadding="0" cellspacing="0">
                        <tr>
                            <td style="border-top-style: solid; border-top-width: 1px; border-color: black" align="right" width="50"><strong>0 / 0</strong></td>
                        </tr>
                    </table>
                </td>
            </tr>
        <?php endif ?>
    <?php endforeach ?>
</table>